-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-structure TabList Animated Indicator code to work better with RTL layouts #3236
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rurikoaraki
reviewed
Nov 21, 2023
rurikoaraki
approved these changes
Nov 28, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rurikoaraki
approved these changes
Nov 30, 2023
This commit simplifies the logic of the animated indicator. Rather than positioning the indicator using a calculated `start` value, we position it using absolute layout values within the tablist. Now, the `useTabAnimation` hook does all the math to figure out the top and left offsets of the indicator, and the styling hook for the animatedIndicator simply uses them to position the `top` and `left` layout props. The container slot of the animated indicator is also removed.
…tive into tablist-rtl-fix
lawrencewin
changed the title
Fix positioning of TabList indicator on RTL layouts
Re-structure TabList Animated Indicator code to work better with RTL layouts
Dec 8, 2023
rurikoaraki
reviewed
Dec 8, 2023
rurikoaraki
reviewed
Dec 8, 2023
rurikoaraki
approved these changes
Dec 9, 2023
PPatBoyd
approved these changes
Dec 12, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Platforms Impacted
Description of changes
Currently, we style and animate the TabList's animated indicator by calculating, setting, and adjusting its
start
layout position. On RTL layouts, thestart
value is calculated by flipping the left offset of a given tab by subtracting it from the width of the tablist. On mac, this also means that the translate transform for JS animations needs to be flipped.While this works, the extra logic to set the
start
layout style results in code that is more complex than it needs to be. This PR changes the approach for positioning the indicator. Instead of calculating thestart
of the indicator, we set its position to be absolute and calculate itsleft
/top
offsets relative to the entire tablist. This removes the need for extra logic on RTL layouts. The code is also re-organized to include all of the layout math inuseTabAnimation
and remove it from the win32'suseAnimatedIndicatorStyles
(unfortunately, math still has to be done on math because we're calculating transforms 😞).Other changes:
Verification
Mac video:
Rtl.mac.final.MOV
Pull request checklist
This PR has considered (when applicable):